

public class PacmanMap {
	
	private final PacmanBoard board;
	private final Point pacmanLocation;
	
	public PacmanMap(final PacmanBoard board) {
		this.board = board;
		this.pacmanLocation = board.getStartLocation();
	}
	
	public PacmanMap(final PacmanMap map, final Point pacmanLocation) {
		this.board = map.getBoard();
		this.pacmanLocation = pacmanLocation;
	}
	
	public final PacmanBoard getBoard() {
		return board;
	}
	
	public final Point getPacmanLocation() {
		return pacmanLocation;
	}
	
	public final PacmanMap setPacmanLocation(Point pacmanLocation) {
		return new PacmanMap(this, pacmanLocation);
	}
	
    public final boolean isTraversable(final Point xyLocation) {
        return board.isLocationEmpty(xyLocation);
    }
	
	public void printMap() {
		char[][] boardCopy = board.getMap();	
		for(int row = 0; row < boardCopy.length; row++) {
			for(int col = 0; col < boardCopy[row].length; col++) {
				if(row == pacmanLocation.getRow() && col == pacmanLocation.getCol())
					System.out.print('P');
				else if(row == board.getFinishLocation().getRow() && col == board.getFinishLocation().getCol())
					System.out.print('.');			
				else
					System.out.print(boardCopy[row][col]);
			}
			System.out.print("\n");
		}
	}

}
